package com.sunshine.schedulegrid.view

import android.content.Context
import android.util.AttributeSet
import android.widget.LinearLayout
import androidx.viewpager.widget.ViewPager
import com.sunshine.schedulegrid.adapter.WeekSlideViewPagerAdapter
import com.sunshine.schedulegrid.config.ScheduleConfig
import com.sunshine.schedulegrid.utils.ColorUtils
import com.sunshine.schedulegrid.utils.CourseList
import com.sunshine.schedulegrid.utils.DateUtils

/**
 * @author sunshine
 * @date 2020/9/3
 * 左右滑动周
 */
class WeekSlideView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0,
    scheduleConfig: ScheduleConfig,
    courseList: CourseList,
    colorUtils: ColorUtils
) : LinearLayout(context, attrs, defStyleAttr) {
    //周容器viewPager
    private val viewPager = ViewPager(context)

    init {
        viewPager.adapter = WeekSlideViewPagerAdapter(
            scheduleConfig = scheduleConfig,
            courseList = courseList,
            colorUtils = colorUtils
        )

        //设置默认展示页为当前周
        viewPager.currentItem = DateUtils.getThisWeek() - 1

        addView(viewPager)
    }
}